package o;

import android.os.Handler;
import android.os.Looper;
import com.huawei.hms.support.api.client.Result;
import com.huawei.hms.support.api.sns.UserUnreadMsgCountResult;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import o.bwp.b;

public class bwq implements bwp, ekn {
    private final CountDownLatch ˊ = new CountDownLatch(1);
    private final Executor ˎ = Executors.newSingleThreadExecutor();
    private e ॱ;

    static class e implements Runnable {
        private static Handler ˎ = new Handler(Looper.getMainLooper());
        private int ˏ;
        private b ॱ;

        e(b bVar) {
            this.ॱ = bVar;
        }

        void ˋ(int i) {
            this.ˏ = i;
            ˎ.post(this);
        }

        public void run() {
            this.ॱ.ˏ(this.ˏ);
        }
    }

    bwq(b bVar) {
        this.ॱ = new e(bVar);
    }

    public void ˊ() {
        bqx.ˊ("SysMsgImpl", "getSysMsgCount");
        this.ˎ.execute(new Runnable(this) {
            final /* synthetic */ bwq ˋ;

            {
                this.ˋ = r1;
            }

            public void run() {
                bqx.ˏ("SysMsgImpl", "getSysMsgCount#run");
                ((eke) cdb.ॱ(eke.class)).ˏ(this.ˋ);
                try {
                    if (!this.ˋ.ˊ.await(2, TimeUnit.SECONDS)) {
                        bqx.ॱ("SysMsgImpl", "getSysMsgCount timeout");
                        this.ˋ.ॱ.ˋ(0);
                    }
                } catch (InterruptedException e) {
                    bqx.ॱ("SysMsgImpl", "InterruptedException");
                    this.ˋ.ॱ.ˋ(0);
                }
            }
        });
    }

    public void ˏ(Result result) {
        bqx.ˏ("SysMsgImpl", "onApiResult");
        if (result instanceof UserUnreadMsgCountResult) {
            this.ˊ.countDown();
            UserUnreadMsgCountResult userUnreadMsgCountResult = (UserUnreadMsgCountResult) result;
            bqx.ˊ("SysMsgImpl", "UserUnreadMsgCountResult, resp.count: " + userUnreadMsgCountResult.getCount());
            this.ॱ.ˋ(userUnreadMsgCountResult.getCount());
        }
    }

    public void ˋ() {
        ((eke) cdb.ॱ(eke.class)).ˋ();
    }
}
